package HelpingClasses;

/**
 * In dieser Klasse werden Methoden bereit gestellt, die das Umrechnen der einzelnen
 * physikalischen Einheiten ineinander ermoeglichen und somit die Ausgabe der Daten
 * erweitert.
 * @author Torbjoern Klatt
 */
public class PhysikEinheiten {
    // Instanzvariablen
    private double metersek, meter, sek;
    private double kmeterh, kmeter, h;
    
    //*******************************
    // Konstruktoren
    /**
     * erzeugt ein Objekt vom Typ PhysikEinheiten
     * @param ms Meter/Sekunde
     * @param km Kilometer
     * @param h Stunden
     */
    public PhysikEinheiten(double ms, double km, double h) {
        this.metersek = ms;
        this.kmeter = km;
        this.h = h;
        this.meter = this.km2m();
        this.sek = this.h2s();
        this.kmeterh = this.ms2kmh();
    }
    
    //*******************************
    // Getter
    /**
     * @return Stunden
     */
    public double getH() {
        return h;
    }

    /**
     * @return Kilometer
     */
    public double getKmeter() {
        return kmeter;
    }
    
    /**
     * @return Kilometer/Stunde
     */
    public double getKmeterh() {
        return kmeterh;
    }

    /**
     * @return Meter
     */
    public double getMeter() {
        return meter;
    }

    /**
     * @return Meter/Sekunde
     */
    public double getMetersek() {
        return metersek;
    }
    
    /**
     * @return Sekunden
     */
    public double getSek() {
        return sek;
    }

    //*******************************
    // Setter
    /**
     * @param h Stunden
     */
    public void setH(double h) {
        this.h = h;
        this.sek = this.h2s();
    }
    
    /**
     * @param kmeter Kilometer
     */
    public void setKmeter(double kmeter) {
        this.kmeter = kmeter;
        this.meter = this.km2m();
    }
    
    /**
     * @param kmeterh Kilometer/Stunde
     */
    public void setKmeterh(double kmeterh) {
        this.kmeterh = kmeterh;
        this.metersek = this.kmh2ms();
    }

    /**
     * @param meter Meter
     */
    public void setMeter(double meter) {
        this.meter = meter;
        this.kmeter = this.m2km();
    }

    /**
     * @param metersek Meter/Sekunde
     */
    public void setMetersek(double metersek) {
        this.metersek = metersek;
        this.kmeterh = this.ms2kmh();
    }
    
    /**
     * @param sek Sekunde
     */
    public void setSek(double sek) {
        this.sek = sek;
        this.h = this.s2h();
    }
    
    //*******************************
    // Instanzmethoden
    /**
     * km/h in m/s
     * @return Meter/Sekunde
     */
    public double kmh2ms() {
        return this.kmeterh*3.6;
    }
    
    /**
     * m/s in km/h
     * @return Kilometer/Stunde
     */
    public double ms2kmh() {
        return this.metersek/3.6;
    }
    
    /**
     * m in km
     * @return Kilometer
     */
    public double m2km() {
        return this.meter*1000;
    }
    
    /**
     * km in m
     * @return Meter
     */
    public double km2m() {
        return this.kmeter/1000;
    }
    
    /**
     * h in s
     * @return Sekunden
     */
    public double h2s() {
        return this.h*3600;
    }
    
    /**
     * s in h
     * @return Stunden
     */
    public double s2h() {
        return this.sek/3600;
    }
}
